package Service;

import DAO.TagDao;
import DAO.UserDao;
import Entities.UserEntity;

import javax.transaction.Transactional;

@Transactional
public class RegisterService
{
    private UserDao userDao;
    private TagDao tagDao;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public UserDao getUserDao() {
        return userDao;
    }

    public TagDao getTagDao() {
        return tagDao;
    }

    public void setTagDao(TagDao tagDao) {
        this.tagDao = tagDao;
    }

    //该方法用于判断是否能注册
    public boolean canRegister(String user_name, String user_password, int loginOrRegister)
    {
        //checkUser返回false表示用户名不能在数据库中找到，即表示该用户名可以注册,则该函数应该返回true
        return !userDao.checkUser(user_name, user_password, loginOrRegister);
    }

    //该方法用于将用户存入数据库
    public boolean addUser(UserEntity ue)
    {
        return userDao.add(ue);
    }

    //该方法用于返回数据库标签表的标签
    public String[] getTags()
    {
        return tagDao.getTags();
    }

}
